import { http } from '@/services/request'
import type { IUnknownObjProps } from '@/interface/base.interface'
import type { PaginatedResponse } from '@/services/request/types'

export const ConfigService = {
  // 新增
  async postObj(data: IUnknownObjProps): Promise<void> {
    return http.post('/api/sys/config', data)
  },
  // 删除
  async deleteObj(id: number): Promise<void> {
    return http.delete(`/api/sys/config/${id}`)
  },
  // 修改
  async putObj(data: IUnknownObjProps): Promise<void> {
    return http.put(`/api/sys/config`, data)
  },
  // 详情
  async getObj(id: number): Promise<IUnknownObjProps> {
    return http.get(`/api/sys/config/${id}`)
  },
  // 列表
  async getList(params: IUnknownObjProps): Promise<IUnknownObjProps[]> {
    return http.get(`/api/sys/config`, params)
  },
  // 分页
  async getPage(params: IUnknownObjProps): Promise<PaginatedResponse<IUnknownObjProps[]>> {
    return http.get(`/api/sys/config`, params)
  },
  // 树结构
  async getTree(params: IUnknownObjProps): Promise<IUnknownObjProps[]> {
    return http.get(`/api/sys/config/tree`, params)
  },
  // 保存
  async saveConfig(data: IUnknownObjProps): Promise<void> {
    return http.post(`/api/sys/config/save`, data)
  },
}
